<template>
  <div class="row justify-content-center">
    <div class="col-8">
      <form name="editForm" role="form" novalidate v-on:submit.prevent="save()">
        <h2 id="roomAdminApp.roomCommunity.home.createOrEditLabel" data-cy="RoomCommunityCreateUpdateHeading">
          Create or edit a RoomCommunity
        </h2>
        <div>
          <div class="form-group" v-if="roomCommunity.id">
            <label for="id">ID</label>
            <input type="text" class="form-control" id="id" name="id" v-model="roomCommunity.id" readonly />
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-community-name">Name</label>
            <input
              type="text"
              class="form-control"
              name="name"
              id="room-community-name"
              data-cy="name"
              :class="{ valid: !$v.roomCommunity.name.$invalid, invalid: $v.roomCommunity.name.$invalid }"
              v-model="$v.roomCommunity.name.$model"
            />
            <div v-if="$v.roomCommunity.name.$anyDirty && $v.roomCommunity.name.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomCommunity.name.maxLength">
                This field cannot be longer than 8 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-community-average">Average</label>
            <input
              type="text"
              class="form-control"
              name="average"
              id="room-community-average"
              data-cy="average"
              :class="{ valid: !$v.roomCommunity.average.$invalid, invalid: $v.roomCommunity.average.$invalid }"
              v-model="$v.roomCommunity.average.$model"
            />
            <div v-if="$v.roomCommunity.average.$anyDirty && $v.roomCommunity.average.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomCommunity.average.maxLength">
                This field cannot be longer than 32 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-community-buildingType">Building Type</label>
            <input
              type="text"
              class="form-control"
              name="buildingType"
              id="room-community-buildingType"
              data-cy="buildingType"
              :class="{ valid: !$v.roomCommunity.buildingType.$invalid, invalid: $v.roomCommunity.buildingType.$invalid }"
              v-model="$v.roomCommunity.buildingType.$model"
            />
            <div v-if="$v.roomCommunity.buildingType.$anyDirty && $v.roomCommunity.buildingType.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomCommunity.buildingType.maxLength">
                This field cannot be longer than 32 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-community-propertyCosts">Property Costs</label>
            <input
              type="text"
              class="form-control"
              name="propertyCosts"
              id="room-community-propertyCosts"
              data-cy="propertyCosts"
              :class="{ valid: !$v.roomCommunity.propertyCosts.$invalid, invalid: $v.roomCommunity.propertyCosts.$invalid }"
              v-model="$v.roomCommunity.propertyCosts.$model"
            />
            <div v-if="$v.roomCommunity.propertyCosts.$anyDirty && $v.roomCommunity.propertyCosts.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomCommunity.propertyCosts.maxLength">
                This field cannot be longer than 8 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-community-propertyCompany">Property Company</label>
            <input
              type="text"
              class="form-control"
              name="propertyCompany"
              id="room-community-propertyCompany"
              data-cy="propertyCompany"
              :class="{ valid: !$v.roomCommunity.propertyCompany.$invalid, invalid: $v.roomCommunity.propertyCompany.$invalid }"
              v-model="$v.roomCommunity.propertyCompany.$model"
            />
            <div v-if="$v.roomCommunity.propertyCompany.$anyDirty && $v.roomCommunity.propertyCompany.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomCommunity.propertyCompany.maxLength">
                This field cannot be longer than 32 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-community-developer">Developer</label>
            <input
              type="text"
              class="form-control"
              name="developer"
              id="room-community-developer"
              data-cy="developer"
              :class="{ valid: !$v.roomCommunity.developer.$invalid, invalid: $v.roomCommunity.developer.$invalid }"
              v-model="$v.roomCommunity.developer.$model"
            />
            <div v-if="$v.roomCommunity.developer.$anyDirty && $v.roomCommunity.developer.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomCommunity.developer.maxLength">
                This field cannot be longer than 32 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-community-buildingNo">Building No</label>
            <input
              type="text"
              class="form-control"
              name="buildingNo"
              id="room-community-buildingNo"
              data-cy="buildingNo"
              :class="{ valid: !$v.roomCommunity.buildingNo.$invalid, invalid: $v.roomCommunity.buildingNo.$invalid }"
              v-model="$v.roomCommunity.buildingNo.$model"
            />
            <div v-if="$v.roomCommunity.buildingNo.$anyDirty && $v.roomCommunity.buildingNo.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomCommunity.buildingNo.maxLength">
                This field cannot be longer than 8 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-community-roomNo">Room No</label>
            <input
              type="text"
              class="form-control"
              name="roomNo"
              id="room-community-roomNo"
              data-cy="roomNo"
              :class="{ valid: !$v.roomCommunity.roomNo.$invalid, invalid: $v.roomCommunity.roomNo.$invalid }"
              v-model="$v.roomCommunity.roomNo.$model"
            />
            <div v-if="$v.roomCommunity.roomNo.$anyDirty && $v.roomCommunity.roomNo.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomCommunity.roomNo.maxLength">
                This field cannot be longer than 8 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-community-nearbyStores">Nearby Stores</label>
            <input
              type="text"
              class="form-control"
              name="nearbyStores"
              id="room-community-nearbyStores"
              data-cy="nearbyStores"
              :class="{ valid: !$v.roomCommunity.nearbyStores.$invalid, invalid: $v.roomCommunity.nearbyStores.$invalid }"
              v-model="$v.roomCommunity.nearbyStores.$model"
            />
            <div v-if="$v.roomCommunity.nearbyStores.$anyDirty && $v.roomCommunity.nearbyStores.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomCommunity.nearbyStores.maxLength">
                This field cannot be longer than 128 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-community-focusNo">Focus No</label>
            <input
              type="text"
              class="form-control"
              name="focusNo"
              id="room-community-focusNo"
              data-cy="focusNo"
              :class="{ valid: !$v.roomCommunity.focusNo.$invalid, invalid: $v.roomCommunity.focusNo.$invalid }"
              v-model="$v.roomCommunity.focusNo.$model"
            />
            <div v-if="$v.roomCommunity.focusNo.$anyDirty && $v.roomCommunity.focusNo.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomCommunity.focusNo.maxLength">
                This field cannot be longer than 8 characters.
              </small>
            </div>
          </div>
        </div>
        <div>
          <button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" v-on:click="previousState()">
            <font-awesome-icon icon="ban"></font-awesome-icon>&nbsp;<span>Cancel</span>
          </button>
          <button
            type="submit"
            id="save-entity"
            data-cy="entityCreateSaveButton"
            :disabled="$v.roomCommunity.$invalid || isSaving"
            class="btn btn-primary"
          >
            <font-awesome-icon icon="save"></font-awesome-icon>&nbsp;<span>Save</span>
          </button>
        </div>
      </form>
    </div>
  </div>
</template>
<script lang="ts" src="./room-community-update.component.ts"></script>
